<template>
  <div class="wrapper">
    <el-form :inline="true">
      <el-form-item>
        <el-dropdown @command="setState">
          <span class="el-dropdown-link">
            {{stateStr}}
            <i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item :command="{title:'全部状态',id:''}">全部状态</el-dropdown-item>
            <el-dropdown-item :command="{title:'启用',id:'1'}">启用</el-dropdown-item>
            <el-dropdown-item :command="{title:'禁用',id:'2'}">禁用</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </el-form-item>
      <el-form-item>
        <el-input placeholder="请输入协议房价编码/协议名称"
          style="width:300px;"
          v-model="search"
          clearable></el-input>
      </el-form-item>
      <el-form-item class="fr">
        <el-button size="small"
          type="primary"
          @click="_add"
          v-has="'priceagreementset'">
          新 增
        </el-button>
      </el-form-item>
      <el-form-item>
        <el-button size="small"
          type="primary"
          @click="_search">
          <i class="el-icon-search"
            style="width:30px"></i>
        </el-button>
      </el-form-item>
      <el-form-item>
        <el-table :data="setheadList">
          <el-table-column label="协议编码"
            prop="num">
          </el-table-column>
          <el-table-column label="协议名称"
            prop="name">
          </el-table-column>
          <el-table-column label="合约协议描述"
            prop="describes">
          </el-table-column>
          <el-table-column label="状态"
            prop="stateCN">
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="text"
                size="small"
                @click="edit(scope.row)"
                v-has="'priceagreementset'">修改</el-button>
              <el-button type="text"
                v-if="scope.row.state == 1 && scope.row.chuncui != 1 "
                size="small"
                @click="_deleteAgreementPrice(2,scope.row.id)"
                v-has="'priceagreementonoff'">禁用</el-button>
              <el-button type="text"
                v-if="scope.row.state == 2"
                size="small"
                @click="_deleteAgreementPrice(1,scope.row.id)"
                v-has="'priceagreementonoff'">启用</el-button>
              <el-button type="text"
                size="small"
                v-if="scope.row.chuncui != 1"
                @click="_deleteAgreementPrice(3,scope.row.id)"
                v-has="'priceagreementdelete'">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-form-item>
      <el-form-item class="fr">
        <el-pagination @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageNum"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </el-form-item>
    </el-form>
    <!-- 新增编辑弹窗 -->
    <el-dialog :title="title"
      :visible.sync="dialogVisible"
      width="1200px">
      <el-form label-width="90px"
        class="dialog">
        <el-form-item label="协议编码"
          required>
          <el-input placeholder="请输入协议编码"
            clearable
            maxlength="30"
            v-model="formData.num"></el-input>
        </el-form-item>
        <el-form-item label="协议名称："
          required>
          <el-input placeholder="请输入协议名称"
            maxlength="30"
            clearable
            v-model="formData.name"></el-input>
        </el-form-item>
        <el-form-item label="协议描述：">
          <el-input placeholder="请输入协议描述"
            v-model="formData.describe"
            clearable
            type="textarea"
            maxlength="50"
            style="width:300px"></el-input>
        </el-form-item>
        <el-checkbox v-model="formData.weekend"
          :disabled="formData.agreement.length>0">是否设置周末价格</el-checkbox>
        <div class="weekList"
          v-if="formData.weekend">
          <el-checkbox-group v-model="formData.weeks"
            :disabled="formData.agreement.length>0">
            <el-checkbox v-for="item in weekList"
              :key="item.id"
              :label="item.id">{{item.title}}</el-checkbox>
          </el-checkbox-group>
        </div>
        <el-form-item label="折扣类型：">
          <el-radio-group v-model="formData.type"
            :disabled="formData.agreement.length>0">
            <el-radio :label="1">按比率折扣</el-radio>
            <el-radio :label="2">费折扣</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item>
          <el-button type="primary"
            size="small"
            class="fr"
            @click="_addRoomPrice">新增房型价格</el-button>
        </el-form-item>
        <el-table style="margin-top:20px"
          :data="formData.agreement">
          <el-table-column label="房型"
            prop="roomName">
          </el-table-column>
          <el-table-column :label="head.label"
            v-for="(head, key) in header"
            :key="key">
            <template slot-scope="scope">
              {{formData.agreement[scope.$index][head.key]}}
              <span v-if="head.key =='discountRate' ||  head.key =='weekendDiscountRate'">%</span>
            </template>
          </el-table-column>
          <el-table-column label="启用时间"
            prop="startTime">
          </el-table-column>
          <el-table-column label="操作"
            width="200">
            <template slot-scope="scope">
              <el-button type="text"
                size="small"
                @click="editRoomPrice(formData.agreement[scope.$index],scope.$index)">修改</el-button>
              <el-button type="text"
                size="small"
                @click="_setFestival(formData.agreement[scope.$index].festivals,scope.$index)">节日价格设置</el-button>
              <el-button type="text"
                size="small"
                @click="formData.agreement.splice(scope.$index,1)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <Log :logList="logList" />
      </el-form>
      <span slot="footer"
        class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary"
          @click="_sure">保存</el-button>
      </span>
    </el-dialog>
    <!-- 新增房型价格 -->
    <el-dialog :title="title"
      :visible.sync="dialogRoomPrice"
      width="400px">
      <el-form label-width="110px">
        <el-form-item label="房型："
          required>
          <el-select v-model="room.roomId"
            @change="selectRoomType">
            <el-option v-for="(item,index) in roomTypeList"
              :key="index"
              :label="item.roomName"
              :value="item.roomId"
              :disabled="item.disabled"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="门市价："
          required>
          <el-input placeholder="请输入门市价"
            v-model="room.chuncuiMoney"
            disabled></el-input>
        </el-form-item>
        <el-form-item label="折后价格："
          required
          v-if="formData.type == 2 ">
          <!-- <el-input placeholder="请输入折后价格"
            v-model="room.discountMoney"
            clearable
            maxlength="5"
            @keyup.native="room.discountMoney=room.discountMoney.replace(/[\u4e00-\u9fa5]/ig,'')"
            v-number-only></el-input> -->
          <el-input-number v-model="room.discountMoney"
            controls-position="right"
            :precision="2"
            size="small"
            :min="0"
            :max="10000"></el-input-number>
        </el-form-item>
        <div v-if="formData.type == 1">
          <el-form-item label="折扣比率："
            required>
            <!-- <el-input placeholder="请输入折扣比率"
              style="width:80%"
              clearable
              v-model="room.discountRate"
              v-number-only
              @keyup.native="room.discountRate=room.discountRate.replace(/[\u4e00-\u9fa5]/ig,'')"
              maxlength="2"></el-input> -->
            <el-input-number v-model="room.discountRate"
              :precision="2"
              controls-position="right"
              size="small"
              :min="0"
              :max="100"></el-input-number>
            <span>%</span>
          </el-form-item>
          <el-form-item label="折扣价格："
            v-if="room.discountRate && room.chuncuiMoney">
            <span>￥{{sum}}</span>
          </el-form-item>
        </div>
        <div v-if="formData.weekend">
          <el-form-item label="周末门市价格："
            required>
            <el-input-number v-model="room.weekendMoney"
              controls-position="right"
              size="small"
              :min="0"
              :precision="2"
              :max="10000"></el-input-number>
          </el-form-item>
          <!-- 周末折扣率 -->
          <div v-if="formData.type == 1">
            <el-form-item label="周末折扣率："
              required>
              <el-input-number v-model="room.weekendDiscountRate"
                controls-position="right"
                size="small"
                :precision="2"
                :min="0"
                :max="100"></el-input-number>
              <span>%</span>
            </el-form-item>
            <el-form-item label="周末折扣价格："
              v-if="room.weekendDiscountRate && room.weekendMoney">
              <span>￥{{_sum}}</span>
            </el-form-item>
          </div>
          <!-- 周末折扣价 -->
          <div v-if="formData.type == 2">
            <el-form-item label="周末折扣价："
              required>
              <el-input-number v-model="room.weekendDiscountMoney"
                controls-position="right"
                size="small"
                :min="0"
                :precision="2"
                :max="10000"></el-input-number>
              <!-- <el-input placeholder="请输入周末折扣价"
                v-model="room.weekendDiscountMoney"
                clearable
                maxlength="5"
                @keyup.native="room.weekendDiscountMoney=room.weekendDiscountMoney.replace(/[\u4e00-\u9fa5]/ig,'')"
                v-number-only></el-input> -->
            </el-form-item>
          </div>
        </div>

      </el-form>
      <span slot="footer"
        class="dialog-footer">
        <el-button @click="dialogRoomPrice = false">取 消</el-button>
        <el-button type="primary"
          @click="_sureRoomPrice">保存</el-button>
      </span>
    </el-dialog>
    <!-- 节假日设置弹窗 -->
    <el-dialog title="节假日设置"
      :visible.sync="dialogVisibleFestival"
      width="800px">
      <el-form>
        <el-form-item>
          <el-table :data="festivaList">
            <el-table-column label="起始时间 - 终止时间"
              width="260">
              <template slot-scope="scope">
                <el-date-picker v-model="scope.row.startEndTime"
                  size="small"
                  value-format="yyyy-MM-dd"
                  type="daterange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期">
                </el-date-picker>
              </template>
            </el-table-column>
            <el-table-column prop="name"
              label="折扣类型">
              <template slot-scope="scope">
                <el-select v-model="scope.row.type">
                  <el-option label="按比率"
                    :value="1"></el-option>
                  <el-option label="按价格"
                    :value="2"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column prop="name"
              width="200"
              label="房价">
              <template slot-scope="scope">
                <!-- <el-input v-model="scope.row.roomPrice"
                  style="width:130px"
                  clearable
                  maxlength="5"
                  :placeholder="scope.row.type ==1 ? '请输入折扣率':'请输入折后价'"
                  @keyup.native="scope.row.roomPrice=scope.row.roomPrice.replace(/[\u4e00-\u9fa5]/ig,'')"
                  v-number-only></el-input>
                <span v-show="scope.row.type==1"> %</span> -->
                <el-input-number v-model="scope.row.roomPrice"
                  controls-position="right"
                  size="small"
                  :min="0"
                  :max="10000"
                  :precision="2"
                  v-show="scope.row.type==2"></el-input-number>
                <el-input-number v-model="scope.row.roomPrice"
                  controls-position="right"
                  size="small"
                  :min="0"
                  :max="100"
                  :precision="2"
                  
                  v-show="scope.row.type==1"></el-input-number>&nbsp;&nbsp;
                <span v-show="scope.row.type==1"> %</span>
              </template>
            </el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-button size="small"
                  type="primary"
                  v-if="scope.$index == festivaList.length-1"
                  @click="_addFestival">
                  +
                </el-button>
                <el-button size="small"
                  @click="_reduceFestival(scope.$index)">
                  -
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-form-item>
      </el-form>
      <span slot="footer"
        class="dialog-footer">
        <el-button @click="dialogVisibleFestival = false">取 消</el-button>
        <el-button type="primary"
          @click="_sureFestival">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {
  getRoomTypeList,
  getAgreementList,
  updateAgreementPrice,
  deleteAgreementPrice,
  getAgreementDetail,
  getAgreementLog
} from "@/public/js/price.js";
import Log from "./log";
import { format } from "@/public/js/util";
export default {
  components: {
    Log
  },
  props: {},
  data() {
    return {
      stateStr: "全部状态",
      state: "",
      pageNum: 1,
      pageSize: 10,
      search: "",
      total: 0,
      setheadList: [],
      dialogVisible: false,
      dialogRoomPrice: false,
      dialogVisibleFestival: false,
      title: "新增协议房价",
      chuncui: 1,
      logList: [],
      weekend: false,
      weeks: [],
      weekList: [
        {
          title: "一",
          id: "1",
          check: false
        },
        {
          title: "二",
          id: "2",
          check: false
        },
        {
          title: "三",
          id: "3",
          check: false
        },
        {
          title: "四",
          id: "4",
          check: false
        },
        {
          title: "五",
          id: "5",
          check: false
        },
        {
          title: "六",
          id: "6",
          check: false
        },
        {
          title: "日",
          id: "7",
          check: false
        }
      ],
      //新增 房型数据
      room: {
        id: "",
        roomId: "",
        roomName: "",
        chuncuiMoney: "",
        discountRate: "",
        discountMoney: "",
        brokerage: "",
        weekendMoney: "",
        weekendDiscountRate: "",
        weekendDiscountMoney: "",
        startTime: "",
        festivals: []
      },
      roomTypeList: [],
      formData: {
        id: "",
        num: "",
        name: "",
        describe: "",
        chuncui: 2,
        type: 1,
        weekend: false,
        weeks: [],
        agreement: [],
        agreement: []
      },
      header: [
        {
          label: "正常门市价",
          key: "chuncuiMoney"
        }
      ],
      __index: "",
      festivaList: [],
      formFestivaList: [],
      handle_index: "",
      isAddRoomPrice: true
    };
  },
  watch: {
    formData: {
      handler(newVal) {
        if (newVal.type == 1) {
          if (!newVal.weekend) {
            this.header = [
              {
                label: "门市价",
                key: "chuncuiMoney"
              },
              {
                label: "正常折扣比率",
                key: "discountRate"
              },
              {
                label: "正常折扣价格",
                key: "discountMoney"
              }
            ];
          } else if (newVal.weekend) {
            this.header = [
              {
                label: "正常门市价",
                key: "chuncuiMoney"
              },
              {
                label: "正常折扣比率",
                key: "discountRate"
              },
              {
                label: "正常折扣价格",
                key: "discountMoney"
              },
              {
                label: "周末门市价",
                key: "weekendMoney"
              },
              {
                label: "周末折扣率",
                key: "weekendDiscountRate"
              },
              {
                label: "周末折扣价格",
                key: "weekendDiscountMoney"
              }
            ];
          }
        } else if (newVal.type == 2) {
          if (!newVal.weekend) {
            this.header = [
              {
                label: "门市价",
                key: "chuncuiMoney"
              },
              {
                label: "折后价格",
                key: "discountMoney"
              }
            ];
          } else if (newVal.weekend) {
            this.header = [
              {
                label: "正常门市价",
                key: "chuncuiMoney"
              },
              {
                label: "正常折后价",
                key: "discountMoney"
              },
              {
                label: "周末门市价",
                key: "weekendMoney"
              },
              {
                label: "周末折扣价格",
                key: "weekendDiscountMoney"
              }
            ];
          }
        }
      },
      deep: true
    }
  },
  computed: {
    sum() {
      this.room.discountMoney =
        parseFloat(this.room.chuncuiMoney) *
        parseFloat(this.room.discountRate) /
        100;
      return isNaN(this.room.discountMoney)
        ? ""
        : this.room.discountMoney.toFixed(2);
    },
    _sum() {
      this.room.weekendDiscountMoney =
        parseFloat(this.room.weekendMoney) *
        parseFloat(this.room.weekendDiscountRate) /
        100;
      return isNaN(this.room.weekendDiscountMoney)
        ? ""
        : this.room.weekendDiscountMoney.toFixed(2);
    }
  },
  methods: {
    //状态查询
    setState(data) {
      this.stateStr = data.title;
      this.state = data.id;
      this.pageNum = 1;
      this.pageSize = 10;
      this._getAgreementList();
    },
    // 搜索
    _search() {
      this.pageNum = 1;
      this.pageSize = 10;
      this._getAgreementList();
    },
    //获取协议房价列表数据
    _getAgreementList() {
      getAgreementList({
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        state: this.state,
        search: this.search
      }).then(res => {
        console.log("协议房价列表", res);
        this.setheadList = res.data.headList;
        this.total = res.data.total;
      });
    },
    // 新增
    _add() {
      this.title = "新增协议房价";
      this.formData = {
        id: "",
        num: "",
        name: "",
        describe: "",
        type: 1,
        weekend: false,
        weeks: [],
        agreement: []
      };
      this._getRoomList();
      this.dialogVisible = true;
    },
    //编辑
    edit(row) {
      this._getAgreementDetail(row.id);
      this._getAgreementLog(row.id);
    },
    //获取 详情数据
    _getAgreementDetail(id) {
      getAgreementDetail({ id: id }).then(res => {
        console.log(res);

        let agreementHead = res.data.agreementHead;
        console.log("agreementHead", agreementHead);
        this.title = "编辑协议房价";
        this.formData = {
          id: agreementHead.id,
          num: agreementHead.priceNum,
          name: agreementHead.priceName,
          describe: agreementHead.describes,
          type: agreementHead.discountType,
          weekend: agreementHead.weekend == 1,
          weeks: agreementHead.weeks,
          agreement: []
        };
        agreementHead.agreements.forEach((item, index) => {
          console.log(item.festivals);
          let festivals = [];
          item.festivals.forEach(i => {
            festivals.push({
              id: i.id,
              startEndTime: [i.startTime, i.endTime],
              type: i.discountType,
              roomPrice: i.roomPrice
            });
          });

          this.formData.agreement.push({
            id: item.id,
            roomId: item.roomId,
            roomName: item.roomName,
            chuncuiMoney: item.chuncuiMoney,
            discountRate: item.discountRate,
            discountMoney: item.discountMoney,
            brokerage: item.brokerage,
            weekendMoney: item.weekendMoney,
            weekendDiscountRate: item.weekendDiscountRate,
            weekendDiscountMoney: item.weekendDiscountMoney,
            startTime: item.startTime,
            festivals: festivals
          });
        });
        console.log(" this.formData", this.formData);
        this._getRoomList();
        this.dialogVisible = true;
      });
    },
    //选择房型
    selectRoomType(roomId) {
      this.roomTypeList.forEach((item, index) => {
        if (item.roomId == roomId) {
          this.room.chuncuiMoney = item.money;
          this.room.roomName = item.roomName;
          this.__index = index;
        }
      });
      console.log(this.room);
    },
    // 设置节日
    _setFestival(festivaList, _index) {
      this.handle_index = _index;
      if (!festivaList.length) {
        this.festivaList = [
          {
            id: "",
            startEndTime: [],
            type: 1,
            roomPrice: ""
          }
        ];
      } else {
        this.festivaList = festivaList;
      }
      this.dialogVisibleFestival = true;
    },
    // 新增 节日数据
    _addFestival() {
      this.festivaList.push({
        id: "",
        startEndTime: [],
        type: 1,
        roomPrice: ""
      });
    },
    // 删除 节日数据
    _reduceFestival(__index) {
      this.festivaList.splice(__index, 1);
    },
    // 设置节日保存
    _sureFestival() {
      //表单验证
      let flag = false;
      this.festivaList.forEach(item => {
        if (!item.startEndTime.length) {
          this.$message.error("请输入开始时间结束时间");
          flag = true;
          return false;
        } else if (!item.roomPrice) {
          this.$message.error("请输入房价");
          flag = true;
          return false;
        }
      });
      if (!flag) {
        this.formData.agreement[this.handle_index].festivals = this.festivaList;
        this.dialogVisibleFestival = false;
      }
    },
    _deleteAgreementPrice(state, id) {
      let info = "";
      if (state == 3) {
        info = "是否删除该条数据?";
      } else if (state == 1) {
        info = "是否启用该条数据?";
      } else {
        info = "是否禁用用该条数据?";
      }
      this.$confirm(info, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        deleteAgreementPrice({
          id: id,
          state: state
        }).then(res => {
          if (!res.data.errCode) {
            this.$message({
              message: "操作成功",
              type: "success"
            });
            this._getAgreementList();
          }
        });
      });
    },
    //获取房型列表
    _getRoomList() {
      getRoomTypeList().then(res => {
        this.roomTypeList = res.data.roomTypeList;
        this.roomTypeList.forEach(item => {
          this.formData.agreement.forEach(i => {
            if (i.roomId == item.roomId) {
              item.disabled = true;
            }
          });
        });
      });
    },
    // 新增协议价格
    _addRoomPrice() {
      if (this.formData.weekend == 1 && !this.formData.weeks.length) {
        this.$message.error("请选择要设置的星期");
        return false;
      }
      this._getRoomList();
      this.isAddRoomPrice = true;
      this.dialogRoomPrice = true;
      this.title = "新增房型价格";
      this.room = {
        id: "",
        roomId: "",
        roomName: "",
        chuncuiMoney: "",
        discountRate: "",
        discountMoney: "",
        brokerage: "",
        weekendMoney: "",
        weekendDiscountRate: "",
        weekendDiscountMoney: "",
        startTime: format(new Date().getTime(), "yyyy-MM-dd"),
        festivals: []
      };
    },
    // 修改房型价格
    editRoomPrice(data, __index) {
      this._getRoomList();
      this.isAddRoomPrice = false;
      this.handle_index = __index;
      this.dialogRoomPrice = true;
      this.title = "修改房型价格";
      this.room = JSON.parse(JSON.stringify(data));
    },
    //保存
    _sure() {
      // 表单验证
      this._updateAgreementPrice();
    },
    // 保存新增房型价格
    _sureRoomPrice() {
      //表单验证
      if (!this.room.roomId) {
        this.$message.error("请选择房型");
        return false;
      }
      if (!this.room.chuncuiMoney) {
        this.$message.error("请输入门市价格");
        return false;
      }
      //非门市价
      if (this.formData.chuncui == 2) {
        if (this.formData.type == 1) {
          if (!this.room.discountRate) {
            this.$message.error("请输折扣率");
            return false;
          }
        } else if (this.formData.type == 2) {
          if (!this.room.discountMoney) {
            this.$message.error("请输折扣价格");
            return false;
          }
          if (this.room.discountMoney > this.room.chuncuiMoney) {
            this.$message.error("折扣价格金额不能大于门市价金额");
            return false;
          }
        }
      }

      if (this.formData.weekend) {
        if (!this.room.weekendMoney) {
          this.$message.error("请输周末门市价");
          return false;
        }
        if (this.formData.type == 1 && this.formData.chuncui == 2) {
          if (!this.room.weekendDiscountRate) {
            this.$message.error("请输周末折扣率");
            return false;
          }
        } else if (this.formData.type == 2) {
          if (!this.room.weekendDiscountMoney) {
            this.$message.error("请输周末折扣价");
            return false;
          }
        }
      }

      if (this.isAddRoomPrice) {
        this.formData.agreement.push(this.room);
      } else {
        let room = this.formData.agreement[this.handle_index];
        room.brokerage = this.room.brokerage;
        room.chuncuiMoney = this.room.chuncuiMoney;
        room.discountMoney = this.room.discountMoney;
        room.discountRate = this.room.discountRate;
        room.roomId = this.room.roomId;
        room.roomName = this.room.roomName;
        room.weekendDiscountMoney = this.room.weekendDiscountMoney;
        room.weekendDiscountRate = this.room.weekendDiscountRate;
        room.weekendMoney = this.room.weekendMoney;
      }
      this.dialogRoomPrice = false;
    },
    // 新增编辑
    _updateAgreementPrice() {
      let data = JSON.parse(JSON.stringify(this.formData));
      data.weekend = this.formData.weekend ? 1 : 2;
      data.agreement.forEach(item => {
        item.festivals.forEach(i => {
          i.startTime = i.startEndTime[0];
          i.endTime = i.startEndTime[1];
          delete i.startEndTime;
        });
      });

      // 表单验证
      if (!data.num) {
        this.$message.error("请输入协议编码");
        return false;
      } else if (!data.name) {
        this.$message.error("请输入协议名称");
        return false;
      }
      if (data.weekend == 1 && !data.weeks.length) {
        this.$message.error("请选择要设置的星期");
        return false;
      }
      console.log("this.data", data);

      // 表单验证
      updateAgreementPrice(data).then(res => {
        if (!res.data.errCode) {
          this.$message({
            message: "操作成功",
            type: "success"
          });
          this.dialogVisible = false;
          this._getAgreementList();
        }
      });
    },
    //获取日志信息
    _getAgreementLog(id) {
      getAgreementLog({ id: id }).then(res => {
        this.logList = res.data.logs;
      });
    },
    // 分页
    handleSizeChange(val) {
      this.pageSize = val;
      this._getAgreementList();
    },
    handleCurrentChange() {
      this.pageNum = val;
      this._getAgreementList();
    }
  },
  created() {
    this._getAgreementList();
  },
  mounted() {}
};
</script>
<style lang="scss" scoped>
.wrapper {
  .dialog {
    .el-input {
      width: 300px;
    }
  }
  .cell {
    display: inline-block;
  }
  .el-range-editor--small {
    width: 100%;
  }
}
</style>